<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page session="false" %>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>
            JAX-WS/SFDC Example - Create Lead
        </title>
        <link rel="stylesheet" href="css/style.css" type="text/css"/>
    </head>
    <script type="text/javascript" >
        function repop()
        {
            document.form.FirstName.value="${param.FirstName}";
            document.form.LastName.value="${param.LastName}";
            document.form.PhoneNumber.value="${param.PhoneNumber}";
            document.form.CompanyName.value="${param.CompanyName}";
        }
    </script>
    <body class="formbody">
        <div class="formposition">
            <form name="form" method="post" action="CreateLead" id="createlead">
                <table class="formbox">
                    <tr>
                        <td>
                            <h2 class="formheader">Create a New Lead</h2>
                            <hr/>
                            <table border="0" cellpadding="5" cellspacing="0" width="100%">
                                <tr>
                                    <td class="formfield">Company Name</td>
                                    <td><input class="formtextbox" type="text" name="CompanyName" id="CompanyName" value=""/></td>
                                </tr>
                                <tr>
                                    <td class="formfield">First Name</td>
                                    <td><input class="formtextbox" type="text" name="FirstName" id="FirstName" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="formfield">Last Name</td>
                                    <td><input class="formtextbox" type="text" name="LastName" id="LastName" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="formfield">Phone Number</td>
                                    <td><input class="formtextbox" type="text" name="PhoneNumber" id="PhoneNumber" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="formsubmit" colspan="2"><input type="submit" value="Create Lead" name="createLead" /></td>
                                </tr>
                            </table>
                            <hr/>
                            <c:choose>
                                <c:when test="${error != null}">
                                    <div class="error">
                                        ${error}
                                    </div>
                                    <hr/>
                                </c:when>
                                <c:when test="${leadId != null}">
                                    <div class="leadurl">
                                        Created <a href="http://login.salesforce.com/${leadId}" target="_blank">${leadId}</a>
                                        <a href="#" onclick="repop();" style="font-weight: normal">(re-pop)</a>

                                    </div>
                                    <hr />
                                </c:when>
                            </c:choose>
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td class="formfooter">
                                        JAX-WS / SFDC Partner Example
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </form>
            <script type="text/javascript">
                document.getElementById('CompanyName').focus();
            </script>
        </div>
    </body>
</html>